namespace Delphi.Mimir.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddCashTransaction : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "fin.pfm_cash_transactions",
                c => new
                    {
                        ctx_id = c.Int(nullable: false, identity: true),
                        ctx_mpd_id = c.Int(nullable: false),
                        ctx_ts = c.DateTime(nullable: false),
                        ctx_amount = c.Decimal(nullable: false, precision: 18, scale: 6),
                        ctx_cur_id = c.Int(nullable: false),
                        ctx_ref_cur_amt = c.Decimal(nullable: false, precision: 18, scale: 6),
                    })
                .PrimaryKey(t => t.ctx_id)
                .ForeignKey("fin.com_currencies", t => t.ctx_cur_id, cascadeDelete: true)
                .ForeignKey("fin.pfm_managed_products", t => t.ctx_mpd_id, cascadeDelete: true)
                .Index(t => t.ctx_mpd_id)
                .Index(t => t.ctx_cur_id);
            
        }
        
        public override void Down()
        {
            DropForeignKey("fin.pfm_cash_transactions", "ctx_mpd_id", "fin.pfm_managed_products");
            DropForeignKey("fin.pfm_cash_transactions", "ctx_cur_id", "fin.com_currencies");
            DropIndex("fin.pfm_cash_transactions", new[] { "ctx_cur_id" });
            DropIndex("fin.pfm_cash_transactions", new[] { "ctx_mpd_id" });
            DropTable("fin.pfm_cash_transactions");
        }
    }
}
